package com.service.impl;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pojo.PassengerOrder;
import com.pojo.User;
import com.pojo.UserAndPassengerOrder;
import com.pojo.Users;
import com.pojo.vo.vo_PassengerOrder;
import com.pojo.vo.vo_ResponseBody;
import com.pojo.vo.vo_User;
import com.pojo.vo.vo_UserAndUsers;
import com.service.OrderService;
import com.utils.JedisClient;
import com.utils.StringUtil;
import com.utils.jedis.JedisClientUser;
import com.alibaba.fastjson.JSONArray;
import com.dao.passengerOrderDao;
import com.dao.passengerOrderStateDao;
import com.dao.userAndPassengerOrderDao;
import com.dao.usersDao;

@Service("orderService")
public class OrderServiceImpl implements OrderService {

	@Autowired
	private usersDao usersDao;

	@Autowired
	private passengerOrderDao passengerOrderDao;

	@Autowired
	private passengerOrderStateDao passengerOrderStateDao;
	@Autowired
	private userAndPassengerOrderDao userAndPassengerOrderDao;

	@Override
	public String insertOnePassengerOrder(PassengerOrder order) {
		if (passengerOrderDao.getPassengerOrderingByUsersId(order.getUsers_id()) != null) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "您当前有单正在进行中"));
		}
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String data = "";
		try {
			Date date = new Date();
			order.setStartTime(new Timestamp(date.getTime()));
			order.setEndTime(new Timestamp(new Date(date.getTime() + 1000 * 60 * 5).getTime()));
			// passengerOrderDao.insertOnePassengerOrder(order);//暂时不插入数据库，存放redis,在结束时redis中取出，存入数据库
			JedisClient jedisClient = new JedisClientUser();

			jedisClient.hset("PassengerOrder1", order.getUsers_id().toString(), JSONArray.toJSONString(order));// 订单+users_id
																												// :
																												// order
		} catch (Exception e) {
			e.printStackTrace();
			data = JSONArray.toJSONString(new vo_ResponseBody(0, 0, "发布拼车信息失败"));
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "发布拼车信息成功"));
	}

	@Override
	public String insertOnePassengerOrder(PassengerOrder order, Integer user_type_id) {
		if (user_type_id == 2 && userAndPassengerOrderDao
				.getUserAndPassengerOrderingByThis_users_id(order.getUsers_id()).size() > 0) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "您当前有单正在进行中"));
		}
		if (user_type_id == 3 && passengerOrderDao.getPassengerOrderingByUsersId(order.getUsers_id()) != null) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "您当前有单正在进行中"));
		}
		String data = "";
		try {
			Date date = new Date();
			order.setStartTime(new Timestamp(date.getTime()));
			order.setEndTime(new Timestamp(new Date(date.getTime() + 1000 * 60 * 5).getTime()));

			TreeSet<Integer> treeSet = new TreeSet<>();
			treeSet.add(order.getUsers_id());
			List<vo_UserAndUsers> userList = usersDao.getUserListByUsersIdList(new ArrayList<>(treeSet));
			String name = userList.get(0).getUser_type_id() == 2 ? "乘客" : "师傅";
			name += userList.get(0).getUser_name().substring(0, 1);
			userList.get(0).setUser_name(name);
			userList.get(0).setPassengerOrder(order);

			// 暂时不插入数据库，存放redis
			JedisClient jedisClient = new JedisClientUser();
			jedisClient.hset("PassengerOrder1", order.getUsers_id().toString(),
					JSONArray.toJSONString(userList.get(0)));// 订单+users_id :
																// order
		} catch (Exception e) {
			data = JSONArray.toJSONString(new vo_ResponseBody(0, 0, "发布拼车信息失败"));
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "发布拼车信息成功"));
	}

	@Override
	public String getAllPassengerOrder(int thisUsers_id, int users_id) {
		passengerOrderDao.getAllPassengerOrder(thisUsers_id, users_id);
		return null;// @Param("thisUsers_id")int
					// thisUsers_id,@Param("users_id")int users_id
	}

	@Override
	public String GetAllPassengerOrder(Integer user_Type_id) {// 得到所有正在等待拼车的信息
		System.out.println("user_Type_id: " + user_Type_id);
		List<vo_UserAndUsers> userList = new ArrayList<>();
		String data = "";
		List<Users> list = null;
		if (user_Type_id == 2) {// 乘客获取司机发布的信息
			list = usersDao.getUsersByUser_type_id(3);
		} else if (user_Type_id == 3) {// 司机获取乘客发布的信息
			list = usersDao.getUsersByUser_type_id(2);
		}
		List<String> values = new ArrayList<>();
		List<PassengerOrder> orderList = new ArrayList<>();
		TreeSet<Integer> treeSet = new TreeSet<>();
		if (list != null) {
			JedisClient jedisClient = new JedisClientUser();
			for (Users users : list) {
				String value = jedisClient.hget("PassengerOrder1", users.getUsers_id().toString());
				if (value != null) {
					values.add(value);
					vo_UserAndUsers vo_userAndUsers = JSONArray.parseObject(value, vo_UserAndUsers.class);
					PassengerOrder passengerOrder = JSONArray.parseObject(
							JSONArray.toJSONString(vo_userAndUsers.getPassengerOrder()), PassengerOrder.class);
					orderList.add(passengerOrder);
					treeSet.add(passengerOrder.getUsers_id());
				}
			}
			Map<Integer, vo_UserAndUsers> map = new HashMap<>();
			userList = usersDao.getUserListByUsersIdList(new ArrayList<>(treeSet));
			for (vo_UserAndUsers vo_UserAndUsers : userList) {
				String name = vo_UserAndUsers.getUser_type_id() == 2 ? "乘客 " : "师傅 ";
				name += vo_UserAndUsers.getUser_name().substring(0, 1);
				vo_UserAndUsers.setUser_name(name);
				map.put(vo_UserAndUsers.getUsers_id(), vo_UserAndUsers);
			}
			userList.clear();
			for (PassengerOrder order : orderList) {
				String str = JSONArray.toJSONString(map.get(order.getUsers_id()));
				vo_UserAndUsers vo_userAndUsers = JSONArray.parseObject(str, vo_UserAndUsers.class);
				vo_userAndUsers.setPassengerOrder(order);
				userList.add(vo_userAndUsers);
			}
			System.out.println("list: " + userList);
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, JSONArray.toJSONString(userList)));
	}

	/*
	 * user_type_id:拼车人类型 , 乘客:2 司机:3 here：本次拼车是谁 , 乘客/司机 here：拼的是谁的车 , 司机/乘客
	 */
	@Override
	public String carPool(Integer user_type_id, Integer here, Integer there) {// 形成拼车关系
		System.out.println("user_type_id: " + user_type_id + " here: " + here + " there: " + there);
		JedisClient jedisClient = new JedisClientUser();
		String order = jedisClient.hget("PassengerOrder1", there.toString());
		vo_UserAndUsers vo_UserAndUsers = JSONArray.parseObject(order, vo_UserAndUsers.class);// 取到拼车的信息
		PassengerOrder passengerOrder =JSONArray.parseObject(JSONArray.toJSONString(vo_UserAndUsers.getPassengerOrder()), PassengerOrder.class);// 取到拼车的信息
		passengerOrder.setState_id(2);// 设置拼车状态
		if (order == null) {// 单子已经不存在则拼车失败
			return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "拼车失败"));
		}

		if (user_type_id == 2) {
			if (userAndPassengerOrderDao.getUserAndPassengerOrderingByThis_users_id(here).size() > 0) {
				return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "您当前有单正在进行中"));
			} else {
				if (passengerOrderDao.getPassengerOrderingByUsersId(there) == null) {// 查找司机单子是否存在
					passengerOrderDao.insertOnePassengerOrder(passengerOrder);// 不存在则
																				// 插入
				}
				passengerOrder = passengerOrderDao.getOnePassengerOrderingByOrder(passengerOrder);// 存在则查找

				int count = userAndPassengerOrderDao.getCountByPassengerOrderId(passengerOrder.getPassengerorder_id());
				if (count < 4) {// 人数<5
					UserAndPassengerOrder userAndPassengerOrder = new UserAndPassengerOrder(
							passengerOrder.getPassengerorder_id(), there, here,
							new Float(passengerOrder.getNotes()).floatValue());
					userAndPassengerOrderDao.insertOneUserAndPassengerOrder(userAndPassengerOrder);
					if (count + 1 >= 4) {
						jedisClient.hdel("PassengerOrder1", there.toString());// 从等待表中删除信息
					}
				} else {
					return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "当前车满人,请刷新"));
				}

			}

		}
		if (user_type_id == 3) {
			if (passengerOrderDao.getPassengerOrderingByUsersId(here) != null) {
				return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "您当前有单正在进行中"));
			} else {

			}
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "拼单失败"));
		}

		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "拼车成功，请前往地图查看具体拼车情况"));
	}

	@Override
	public String getThisCarPool(Integer this_users_id, Integer user_type_id) {
		TreeSet<Integer> treeSet = new TreeSet<>();
		Map<Integer, vo_UserAndUsers> map = new HashMap<>();
		List<vo_UserAndUsers> userList = new ArrayList<>();
		PassengerOrder passengerOrder = null;
		if (user_type_id == 2) {// 乘客获取当前司机对象
			List<UserAndPassengerOrder> list = userAndPassengerOrderDao
					.getUserAndPassengerOrderingByThis_users_id(this_users_id);
			vo_UserAndUsers vo_userAndUsers = null;
			if (list.size() > 0) {
				passengerOrder = passengerOrderDao.getPassengerOrderingByUsersId(list.get(0).getTarget_users_id());
				passengerOrder.setState_id(list.get(0).getState_id());
				treeSet.add(list.get(0).getTarget_users_id());
				userList = usersDao.getUserListByUsersIdList(new ArrayList<>(treeSet));
				for (vo_UserAndUsers vo_UserAndUsers : userList) {
					map.put(vo_UserAndUsers.getUsers_id(), vo_UserAndUsers);
				}
				vo_userAndUsers = map.get(list.get(0).getTarget_users_id());
				vo_userAndUsers.setUser_name(
						vo_userAndUsers.getUser_name().substring(0, 1) + "师傅(" + vo_userAndUsers.getUser_sex() + ") "
								+ StringUtil.formatMobile(vo_userAndUsers.getUser_tel()));
				vo_userAndUsers.setPassengerOrder(passengerOrder);
			}
			userList.clear();
			if (passengerOrder != null && vo_userAndUsers != null) {
				userList.add(vo_userAndUsers);
				return JSONArray.toJSONString(new vo_ResponseBody(0, 0, JSONArray.toJSONString(userList)));
			}
		}
		if (user_type_id == 3) {// 司机获取当前接单用户
			passengerOrder = passengerOrderDao.getPassengerOrderingByUsersId(this_users_id);// 获取司机的路线
			if (passengerOrder != null) {
				List<PassengerOrder> passengerOrderlist = new ArrayList<>();
				List<UserAndPassengerOrder> list = userAndPassengerOrderDao
						.getUserAndPassengerOrderByPassengerOrderId(passengerOrder.getPassengerorder_id());
				for (UserAndPassengerOrder userAndPassengerOrdr : list) {
					passengerOrder.setUsers_id(userAndPassengerOrdr.getThis_users_id());
					passengerOrder.setState_id(userAndPassengerOrdr.getState_id());
					PassengerOrder order = JSONArray.parseObject(JSONArray.toJSONString(passengerOrder),
							PassengerOrder.class);
					passengerOrderlist.add(order);
					treeSet.add(userAndPassengerOrdr.getThis_users_id());
				}
				userList = usersDao.getUserListByUsersIdList(new ArrayList<>(treeSet));
				for (vo_UserAndUsers vo_UserAndUsers : userList) {
					vo_UserAndUsers.setUser_name(vo_UserAndUsers.getUser_name().substring(0, 1)
							+ (vo_UserAndUsers.getUser_sex().equals("男") ? "先生 " : "女士 ")
							+ StringUtil.formatMobile(vo_UserAndUsers.getUser_tel()));
					map.put(vo_UserAndUsers.getUsers_id(), vo_UserAndUsers);
				}
				userList.clear();
				for (PassengerOrder order : passengerOrderlist) {
					String str = JSONArray.toJSONString(map.get(order.getUsers_id()));
					vo_UserAndUsers vo_userAndUsers = JSONArray.parseObject(str, vo_UserAndUsers.class);
					vo_userAndUsers.setPassengerOrder(order);
					userList.add(vo_userAndUsers);
				}
				return JSONArray.toJSONString(new vo_ResponseBody(0, 0, JSONArray.toJSONString(userList)));
			}
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "暂无"));
	}

	@Override
	public String endOrderByUsers_id(Integer target_users_id, Integer user_type_id, Integer this_users_id) {
		System.out.println("target_users_id : " + target_users_id + "  user_type_id : " + user_type_id
				+ "  this_users_id : " + this_users_id);
		PassengerOrder passengerOrder = null;
		if (user_type_id == 2) {
			if (1 == userAndPassengerOrderDao.updateStateByThisUsers_id(target_users_id, this_users_id)) {// 设置状态为乘客取消
				Integer passengerOrder_id = userAndPassengerOrderDao.getPassengerOrderIdByThisUsers_id(target_users_id,
						this_users_id);
				passengerOrder = passengerOrderDao.getPassengerOrderingByPassengerOrderId(passengerOrder_id);
				JedisClient jedisClient = new JedisClientUser();
				jedisClient.hset("PassengerOrder1", passengerOrder.getUsers_id().toString(),
						JSONArray.toJSONString(passengerOrder));
				return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "取消订单成功"));
			} else {
				return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "请刷新页面同步数据"));
			}
		}
		if (user_type_id == 3) {
			System.out.println("\n司机取消\n");
			// passengerOrder=passengerOrderDao.getPassengerOrderingByUsersId(this_users_id);
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "取消订单失败"));
	}

	@Override
	public String editStateToing(Integer this_user_id, Integer passengerorder_id) {
		if (userAndPassengerOrderDao.editStateToing(this_user_id, passengerorder_id) == 1) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "用户已上车"));
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "用户已取消订单，请重试"));
	}

	@Override
	public String editStateToEnd(Integer this_user_id, Integer passengerorder_id) {
		System.out.println("this_user_id:" + this_user_id + "  passengerorder_id:" + passengerorder_id);
		int i = userAndPassengerOrderDao.editStateToEnd(this_user_id, passengerorder_id);
		if (i == 1) {//
			if (userAndPassengerOrderDao.getCountByPassengeringOrderId(passengerorder_id) <= 0) {// <=0，代表乘客全部到达终点
				if (passengerOrderDao.setPassengerOrderEndByPassengerorder_id(passengerorder_id) == 1) {// 修改总订单已到达目的地
					return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "乘客已全部到达终点"));
				}
			}
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "到达终点"));
		} else if (i < 1) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "该订单已不存在"));
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "数据不同步,请刷新页面"));
	}

	@Override
	public String GetAllEndPassengerOrder(Integer user_type_id, Integer users_id) {// 得到已经完成的单子
		List<vo_PassengerOrder> passengerOrderlist = new ArrayList<>();
		TreeSet<Integer> treeSet = new TreeSet<>();
		Map<Integer, vo_UserAndUsers> map = new HashMap<>();
		List<vo_UserAndUsers> userList = new ArrayList<>();
		if (user_type_id == 3) {
			List<vo_PassengerOrder> thisList = passengerOrderDao.GetAllEndPassengerOrderByThree(users_id);
			passengerOrderlist.addAll(thisList);
			List<vo_PassengerOrder> otherList = passengerOrderDao.GetAllEndPassengerOrderByThreeUnion(users_id);
			passengerOrderlist.addAll(otherList);
			if(passengerOrderlist.size()<=0){
				return JSONArray.toJSONString(new vo_ResponseBody(0, -1, JSONArray.toJSONString("无完成的拼单")));
			}
			for (vo_PassengerOrder vo_PassengerOrder : passengerOrderlist) {
				treeSet.add(vo_PassengerOrder.getUsers_id());
			}
			userList = usersDao.getUserListByUsersIdList(new ArrayList<>(treeSet));
			for (vo_UserAndUsers vo_UserAndUsers : userList) {
				vo_UserAndUsers.setUser_name(vo_UserAndUsers.getUser_name().substring(0, 1)
						+ (vo_UserAndUsers.getUser_sex().equals("男") ? "先生 " : "女士 ")
						+ StringUtil.formatMobile(vo_UserAndUsers.getUser_tel()));
				map.put(vo_UserAndUsers.getUsers_id(), vo_UserAndUsers);
			}
			userList.clear();
			for (vo_PassengerOrder vo_PassengerOrder : passengerOrderlist) {
				String str = JSONArray.toJSONString(map.get(vo_PassengerOrder.getUsers_id()));
				vo_UserAndUsers vo_userAndUsers = JSONArray.parseObject(str, vo_UserAndUsers.class);
				vo_userAndUsers.setPassengerOrder(vo_PassengerOrder);
				userList.add(vo_userAndUsers);
			}
			if (passengerOrderlist.size() > 0) {
				return JSONArray.toJSONString(new vo_ResponseBody(0, 0, JSONArray.toJSONString(userList)));
			}
		} else if (user_type_id == 2) {
			List<vo_PassengerOrder> thisList = passengerOrderDao.GetAllEndPassengerOrderByThree(users_id);
			passengerOrderlist.addAll(thisList);
			List<vo_PassengerOrder> otherList = passengerOrderDao.GetAllEndPassengerOrderByThreeUnion(users_id);
			for (vo_PassengerOrder vo_passengerOrder : otherList) {
				vo_passengerOrder.setUsers_id(users_id);
				vo_PassengerOrder order = JSONArray.parseObject(JSONArray.toJSONString(vo_passengerOrder),
						vo_PassengerOrder.class);
				passengerOrderlist.add(order);
			}
			if(passengerOrderlist.size()<=0){
				return JSONArray.toJSONString(new vo_ResponseBody(0, -1, JSONArray.toJSONString("无完成的拼单")));
			}
			for (vo_PassengerOrder vo_PassengerOrder : passengerOrderlist) {
				treeSet.add(vo_PassengerOrder.getUsers_id());
			}
			System.out.println("1:"+passengerOrderlist);
			System.out.println("1:"+treeSet);
			userList = usersDao.getUserListByUsersIdList(new ArrayList<>(treeSet));
			System.out.println("2:"+treeSet);
			for (vo_UserAndUsers vo_UserAndUsers : userList) {
				vo_UserAndUsers.setUser_name(
						vo_UserAndUsers.getUser_name().substring(0, 1) + "师傅(" + vo_UserAndUsers.getUser_sex() + ") "
								+ StringUtil.formatMobile(vo_UserAndUsers.getUser_tel()));
				map.put(vo_UserAndUsers.getUsers_id(), vo_UserAndUsers);
			}
			userList.clear();
			for (vo_PassengerOrder vo_PassengerOrder : passengerOrderlist) {
				String str = JSONArray.toJSONString(map.get(vo_PassengerOrder.getUsers_id()));
				vo_UserAndUsers vo_userAndUsers = JSONArray.parseObject(str, vo_UserAndUsers.class);
				vo_userAndUsers.setPassengerOrder(vo_PassengerOrder);
				userList.add(vo_userAndUsers);
			}
			if (passengerOrderlist.size() > 0) {
				return JSONArray.toJSONString(new vo_ResponseBody(0, 0, JSONArray.toJSONString(userList)));
			}
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "暂无"));
	}

	@Override
	public String getTargetUserByOrderId(Integer userAndPassengerOrder_id, Integer user_type_id) {
		System.out.println("userAndPassengerOrder_id:" + userAndPassengerOrder_id + "  user_type_id:" + user_type_id);
		User user = userAndPassengerOrderDao.getTargetUserByOrderId(userAndPassengerOrder_id,
				user_type_id == 2 ? 3 : 2);
		vo_User vo_user = null;
		if (user == null) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, -1, ""));
		}
		StringBuilder sb = new StringBuilder();
		sb.append(user.getUser_name().substring(0, 1));
		sb.append(user_type_id == 2 ? "师傅(" + user.getUser_sex() + ")" : user.getUser_sex().equals("男") ? "先生" : "女士");
		vo_user = new vo_User(sb.toString(),
				user.getUser_tel().substring(0, 3) + "****" + user.getUser_tel().substring(7, 11),
				user_type_id == 2 ? 3 : 2);
		return JSONArray.toJSONString(new vo_ResponseBody(0, 0, JSONArray.toJSONString(vo_user)));
	}

	@Override
	public String payMoney(Integer userAndPassengerOrder_id, float price) {
		UserAndPassengerOrder userAndPassengerOrder = userAndPassengerOrderDao
				.getOneUserAndPassengerOrderByIdAndPrice(userAndPassengerOrder_id);
		if (userAndPassengerOrder == null || userAndPassengerOrder.getPrice() != price) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "支付失败,请刷新订单再支付"));
		}
		if (userAndPassengerOrderDao.payMoney(userAndPassengerOrder_id, price) > 0) {
			return JSONArray.toJSONString(new vo_ResponseBody(0, 0, "支付成功"));
		}
		return JSONArray.toJSONString(new vo_ResponseBody(0, -1, "支付失败"));
	}

	// @Override
	// public String carPool(Integer user_type_id, Integer here, Integer there)
	// {//形成拼车关系
	// System.out.println("user_type_id :"+user_type_id+" ,here :"+here+" ,there
	// :"+there);
	// JedisClient jedisClient=new JedisClientUser();
	// String order=jedisClient.hget("PassengerOrder1", there.toString());
	// PassengerOrder passengerOrder=JSONArray.parseObject(order,
	// PassengerOrder.class);//取到拼车的信息
	// passengerOrder.setState_id(2);// 设置拼车状态
	// if(order==null){
	// return JSONArray.toJSONString(new vo_ResponseBody(0,-1,"拼车失败"));
	// }
	// jedisClient.hdel("PassengerOrder1", there.toString());//从等待表中删除信息
	//
	// if(user_type_id==2){// 乘客 拼车，只需要存放关系，并，删除自己发出的拼车信息，从PassengerOrder1中
	// jedisClient.hdel("PassengerOrder1", here.toString());//从等待表中删除 乘客 自己发出的信息
	// jedisClient.hset("PassengerOrdering", here.toString(),
	// JSONArray.toJSONString(passengerOrder));//进行中
	//// jedisClient.hset("carPool1", here.toString(),
	// there.toString());//拼车对象关系存放 1->n 乘客 司机
	// String allUsers=jedisClient.hget("carPool1", there.toString());//得到
	// 该司机对应的乘客
	// List<Integer> list=JSONArray.parseArray(allUsers, Integer.class);
	// if(allUsers!=null && allUsers.length()>0){
	// list.add(here);
	// jedisClient.hset("carPool1", there.toString()
	// ,JSONArray.toJSONString(list));//司机对应的所有乘客
	// }else{
	// list=new ArrayList<>();
	// list.add(here);
	// jedisClient.hset("carPool1", there.toString()
	// ,JSONArray.toJSONString(list));//司机对应的所有乘客
	// }
	// }
	//
	// if(user_type_id==3){// 司机接乘客，需要删除乘客拼车信息
	// ，在PassengerOrder1中，放到PassengerOrdering中，司机成为路线主人
	// String allUsers=jedisClient.hget("carPool1", here.toString());
	// List<Integer> list=JSONArray.parseArray(allUsers, Integer.class);
	// if(allUsers!=null && allUsers.length()>0){
	// list.add(there);
	// jedisClient.hset("carPool1", here.toString()
	// ,JSONArray.toJSONString(list));//司机对应的所有乘客
	// }else{
	// list=new ArrayList<>();
	// list.add(there);
	// jedisClient.hset("carPool1", here.toString()
	// ,JSONArray.toJSONString(list));//司机对应的所有乘客
	// }
	// jedisClient.hdel("PassengerOrder1", here.toString());//从等待表中删除信息
	//// jedisClient.hset("carPool1", there.toString(), here.toString());//司机对路线
	// jedisClient.hset("PassengerOrdering", there.toString(),
	// JSONArray.toJSONString(passengerOrder));//拼车订单存放
	// }
	// return JSONArray.toJSONString(new
	// vo_ResponseBody(0,0,"拼车成功，请前往地图查看具体拼车情况"));
	// }

}
